home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / graphics / 3dvect37.zip / LAND.ASM < prev    next >
Assembly Source File  |  1994-06-22  |  4KB  |  131 lines

  1. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  2. ;
  3. ; Filename     : land.asm
  4. ; Included from: Main Assembley Module
  5. ; Description  : Draw Background Horizon
  6. ;
  7. ; Written by: John McCarthy
  8. ;             1316 Redwood Lane
  9. ;             Pickering, Ontario.
  10. ;             Canada, Earth, Milky Way (for those out-of-towners)
  11. ;             L1X 1C5
  12. ;
  13. ; Internet/Usenet:  BRIAN.MCCARTHY@CANREM.COM
  14. ;         Fidonet:  Brian McCarthy 1:229/15
  15. ;   RIME/Relaynet: ->CRS
  16. ;
  17. ; Home phone, (905) 831-1944, don't call at 2 am eh!
  18. ;
  19. ; Send me your protected mode source code!
  20. ; Send me your Objects!
  21. ; But most of all, Send me a postcard!!!!
  22. ;
  23. ; Simple non-rotatable background landscape.  Cannot be used with z rotations
  24. ; that is - it only draws a flat backgound landscape.  Use this  in  place of
  25. ; clear_fill routine.  This routine wipes all video memory within the current
  26. ; clipping parameters and puts the "landscape" in the background.
  27. ;
  28. ; This routine does not compensate for the height of the camera! the  scaling
  29. ; of the colours on the "ground" do not become tighter  as  the  camera  gets
  30. ; closer to the ground.  Someday, no today, I will make a routine which  does
  31. ; full flight simulator backgounds.
  32. ;
  33. ; NOTE: This routine sets the flag useclear=no and therefore  shuts  off  the
  34. ;       clear_fill routine in poly.inc.  This is done since  screen  clearing
  35. ;       is done at the same time as drawing the background landscape.
  36. ;
  37. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  38.  
  39.         .386p
  40.         jumps
  41.  
  42. code32  segment para public use32
  43.         assume cs:code32, ds:code32
  44.  
  45.         include pmode.ext       ; protected mode externals by TRAN
  46.         include xmouse.ext      ; xmode mouse externals
  47.         include xmode.ext       ; xmode externals by matt pritchard
  48.         include irq.ext
  49.         include 3d.ext
  50.         include stars.ext
  51.         include font.ext
  52.  
  53.         include macros.inc
  54.         include equ.inc
  55.  
  56.         public draw_landscape
  57.  
  58.         sky equ 0      ; colours...
  59.         ground equ 84
  60.  
  61. draw_landscape:
  62.         out_8 sc_data, all_planes   ; write to all planes
  63.  
  64.         mov ax,eyeax            ; y = ratiox * (z * 20) / (z * 32) (horizon)
  65.         or ax,ax
  66.         jz doit_a
  67.  
  68.         call cosign             ; find horizon = tan(x xangle) * 1024
  69.         push eax
  70.         mov ax,eyeax
  71.         call sign
  72.         mov ebx,eax
  73.         cmul eax,ebx,yactual
  74.         pop ecx
  75.         cdq
  76.         idiv ecx
  77. doit_a:
  78.         mov si,ax
  79.         add si,ymins
  80.         sub si,8*yactual/400
  81.  
  82.         movzx edi,cliptp
  83.         mov edi,fastimultable[edi*4]
  84.         movzx ecx,cliplt
  85.         shr ecx,2
  86.         add edi,ecx
  87.         add edi,current_page
  88.  
  89.         mov dx,ymaxs   ; dx = counter
  90.         sub dx,ymins
  91.         movzx edx,dx
  92.  
  93.         movzx ecx,xmaxs
  94.         sub cx,xmins
  95.         mov ebx,xactual
  96.         sub bx,cx
  97.         shr ebx,2
  98.         shr cx,3        ; /4/2
  99.         mov ebp,ecx
  100.         mov ax,sky*256+sky  ; background sky colour
  101.  
  102. plot_loop1:
  103.         cmp si,0       ; check for horizon
  104.         jge here_s_johnny
  105.         mov ecx,ebp
  106. pl_1x:
  107.         rep stosw
  108.         add edi,ebx
  109.         inc esi
  110.         dec edx
  111.         jnz plot_loop1
  112.  
  113.         ret
  114.  
  115. here_s_johnny:
  116.         mov ax,ground*256+ground  ; background ground colour
  117.  
  118. plot_loop2:
  119.         mov ecx,ebp
  120. pl_2x:
  121.         rep stosw
  122.         add edi,ebx
  123.         dec edx
  124.         jnz plot_loop2
  125.  
  126.         ret
  127.  
  128. code32  ends
  129.         end
  130.  
  131.